package com.pavan.nightclock;

import java.util.Calendar;
import java.util.List;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.widget.Toast;

public class NightclockGpsActivity extends Activity {
    /** Called when the activity is first created. */
	
	
	
	public int textColor;
	public int textFont;
	final int MENU_ALARM = 1;
    final int MENU_TEXT_COLOR = 2;
    final int MENU_TEXT_FONT_NORMAL = 3;
    final int MENU_TEXT_FONT_DIGITEK = 4;
    final int MENU_TEXT_FONT_ELECTRON = 7;
    final int MENU_TEXT_FONT_SEGMENT = 5;
    final int MENU_GPSALARM = 6;
    final int DIALOG_COLOR_PICKER = 1;
    final int FONT_NORMAL = 1;
    final int FONT_COMPUTER = 2;
    final int FONT_DIGITEK = 3;
    final int FONT_ELECTRON = 4;
    final int FONT_SEGMENT = 5;
	
    public boolean onCreateOptionsMenu(Menu menu) {
    	menu.add(0, MENU_ALARM, 0, "Alarm");
    	menu.add(0, MENU_TEXT_COLOR, 0, "Color");
    	SubMenu fontMenu = menu.addSubMenu("Font");
    	fontMenu.add(0, MENU_TEXT_FONT_NORMAL, 0, "NORMAL");
    	fontMenu.add(0, MENU_TEXT_FONT_DIGITEK, 0, "DIGITEK FONT");
    	fontMenu.add(0, MENU_TEXT_FONT_ELECTRON, 0, "ELECTRON FONT");
    	fontMenu.add(0, MENU_TEXT_FONT_SEGMENT, 0, "SEVEN SEGMENT");
    	menu.add(0, MENU_GPSALARM, 0, "GPS Alarm");
   
    	return true;
    }
    public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
	}
    
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) 
        {
        	case MENU_ALARM:
	        	Intent i = new Intent();
		        i.setClassName("com.android.alarmclock", "com.android.alarmclock.AlarmClock");
	        	if(isIntentAvailable(i))
	        	{
	        		startActivity(i);
	        	}
	        	else
	        	{
	        		Context context = getApplicationContext();
	        		CharSequence text = "Sorry, this feature isn't enabled on your phone yet.";
	        		int duration = Toast.LENGTH_SHORT;

	        		Toast toast = Toast.makeText(context, text, duration);
	        		toast.show();
	        	}
	            return true;
	        case MENU_TEXT_COLOR:
	        	showDialog(DIALOG_COLOR_PICKER);
	            return true;
	        case MENU_TEXT_FONT_NORMAL:
	        	setTextFont(FONT_NORMAL);
	            return true;
	        case MENU_TEXT_FONT_DIGITEK:
	        	setTextFont(FONT_COMPUTER);
	            return true;
	        case MENU_TEXT_FONT_SEGMENT:
	        	setTextFont(FONT_SEGMENT);
	            return true;
	        case MENU_GPSALARM:
	        	Context context = getApplicationContext();
	        	Intent j = new Intent(context,gps.class);     
	        	startActivity(j);
	        	return true;
}
        return false;
    }
    private colorchooser.OnColorChangedListener mColorChangedListener =
            new colorchooser.OnColorChangedListener() {
        		public void colorChanged(int color) {
                    textColor = color;
                   
                    
                }
            };
    @Override
    protected Dialog onCreateDialog(int id) {
        switch (id) {
        case DIALOG_COLOR_PICKER:
            return new colorchooser(this,mColorChangedListener, textColor);
        }
        return null;
    }
    
    public boolean isIntentAvailable(Intent intent) {
        PackageManager packageManager = getPackageManager();
        List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
        return list.size() > 0;
    }
    
    void setTextFont(int fontNum)
    {
    	
	 }
    
}